/**
 * 
 */
package com.security.frame.seccion.config;

import com.security.frame.core.logout.MyLogoutSuccessHandel;
import com.security.frame.core.properties.SecurityProperties;
import com.security.frame.seccion.session.MyExpiredSessionStrategy;
import com.security.frame.seccion.session.MyInvalidSessionStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
import org.springframework.security.web.session.InvalidSessionStrategy;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;


/**
 * todo
 *
 * @author wangjie
 * @version V1.0
 * @date 2019/11/7
 */
@Configuration
public class SessionSecurityBeanConfig {

	@Autowired
	private SecurityProperties securityProperties;
	
	@Bean
	@ConditionalOnMissingBean(InvalidSessionStrategy.class)
	public InvalidSessionStrategy invalidSessionStrategy(){
		return new MyInvalidSessionStrategy(securityProperties.getSession().getSessionInvalidUrl());
	}
	
	@Bean
	@ConditionalOnMissingBean(SessionInformationExpiredStrategy.class)
	public SessionInformationExpiredStrategy sessionInformationExpiredStrategy(){
		return new MyExpiredSessionStrategy(securityProperties.getSession().getSessionInvalidUrl());
	}

}
